<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!doctype html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title>后台管理</title>
    <link rel="stylesheet" type="text/css" href="../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../css/main.css"/>
    <link href="http://hovertree.com/texiao/hovertreeshow/hovertreeshow.css" rel="stylesheet" />
    <script src="http://down.hovertree.com/jquery/jquery-1.12.1.min.js"></script>
</head>
<%
    try {
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;
        Class.forName("org.h2.Driver");
        /*url后面加的?useUnicode=true&characterEncoding=gbk，是为了处理向数据库中添加数据时出现乱码的问题。*/
        String url = "jdbc:h2:~/test5";
        con = DriverManager.getConnection(url, "sa", "sa");
        stmt = con.createStatement();
        String sql =  "select * from shop ";
        rs = stmt.executeQuery(sql);
%>
<body>
<script src="http://hovertree.com/texiao/hovertreeshow/hovertreeshow.js"></script>
<div class="topbar-wrap white">
    <div class="topbar-inner clearfix">
        <div class="topbar-logo-wrap clearfix">
            <h1 class="topbar-logo none"><a href="../index.jsp" class="navbar-brand">后台管理</a></h1>
            <ul class="navbar-list clearfix">
                <li><a class="on" href="#">首页</a></li>
                <li><a href="#" target="#">网站首页</a></li>
            </ul>
        </div>
        <div class="top-info-wrap">
            <ul class="top-info-list clearfix">
                <li><a href="#">管理员</a></li>
                <li><a href="#">修改密码</a></li>
                <li><a href="#">退出</a></li>
            </ul>
        </div>
    </div>
</div>
<div class="container clearfix">
    <div class="sidebar-wrap">
        <div class="sidebar-title">
            <h1>菜单</h1>
        </div>
        <div class="sidebar-content">
            <ul class="sidebar-list">
                <li>
                    <a href="#"><i class="icon-font">&#xe003;</i>人事管理</a>
                    <ul class="sub-menu">
                        <li><a href="design.html"><i class="icon-font">&#xe008;</i>部门管理</a></li>
                        <li><a href="design.html"><i class="icon-font">&#xe005;</i>员工管理</a></li>
                    </ul>
                </li>
                <li>
                    <a href="#"><i class="icon-font">&#xe018;</i>业务管理</a>
                    <ul class="sub-menu">
                        <li><a href="../UserManager/user.jsp"><i class="icon-font">&#xe046;</i>用户管理</a></li>
                        <li><a href="shop.jsp"><i class="icon-font">&#xe033;</i>店铺管理</a></li>
                        <li><a href="../ProductManager/product.jsp"><i class="icon-font">&#xe006;</i>商品管理</a></li>
                        <li><a href="../OrderManager/order.jsp"><i class="icon-font">&#xe006;</i>订单管理</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="../index.jsp">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">店铺管理</span></div>
        </div>
        <div class="search-wrap">
            <div class="search-content">
                <form action="shopkey.jsp" method="post">
                    <table class="search-tab">
                        <tr>
                            <th width="70">关键字:</th>
                            <td><input class="common-text" placeholder="商店名关键字" name="key" value="" id="key" type="text"></td>
                            <td><input class="btn btn-primary btn2" name="sub" value="查询" type="submit" onclick="return myFunction()"></td>
                        </tr>
                    </table>
                    <script>
                        function myFunction() {
                            var text=document.getElementById("key").value;
                            var textValue = text.replace(/(^\s*)|(\s*$)/g, "");
                            if ( textValue=="")
                            {
                                alert('没有关键词');
                                return false;
                            }
                            return true;
                        }
                    </script>
                </form>
            </div>
        </div>
        <div class="result-wrap">
            <form name="myform" id="myform" method="post">
                <div class="result-title">
                    <div class="result-list">
                        <a href="shop_insert.jsp"><i class="icon-font"></i>新增店铺</a>
                    </div>
                </div>
                <div class="result-content">
                    <table class="result-tab" width="100%">
                        <tr>
                            <th>店铺照片</th>
                            <th>ID</th>
                            <th>店名</th>
                            <th>简介</th>
                            <th>操作</th>
                        </tr>
                        <% while (rs.next()) { //取得下一条记%>
                        <tr>
                            <td><div id="hovertreeshow" class="hovertreeshow">
                                <img src="<%="/picture/"+rs.getString("sh_image")%>" style="width: 30px;height: 30px" />
                            </div>
                            </td>
                            <td><%=rs.getInt("sh_id")%></td>
                            <td><%=rs.getString("sh_name")%></td>
                            <td><%=rs.getString("text")%></td>
                            <td>
                                <a class="link-update" href="shop_update.jsp?str=<%=String.valueOf(rs.getInt("sh_id"))%>">修改</a>
                                <a class="link-del" href="/final/Delshop?str=<%=rs.getInt("sh_id")%>">删除</a>
                            </td>
                        </tr>
                        <% } %>
                    </table>
                </div>
            </form>
        </div>
    </div>
    <!--/main-->
</div>
</body>
<%
        rs.close();
        stmt.close();
        con.close();
    }catch (Exception e){e.getMessage();}

%>
</html>